uniform sampler2D tex;
uniform sampler2D depth;

uniform float maxDepth;

void main() {
	vec4 color = texture2D(tex, gl_TexCoord[0].st);
	vec4 depthValue = texture2D(depth, gl_TexCoord[0].st);
	
	gl_FragColor = color;
	gl_FragDepth = clamp(depthValue.x * maxDepth, 0.0, 1.0);
}
